public class Singleton{
    //私有静态实例
    private static Singleton instance;

    //私有构造函数，防止实例化
    private Singleton(){}

    //公共静态方法返回唯一实例
    public static synchronized Singleton getInstance(){
        if(instance == null){
            instance = new Singleton();
        }
        return instance;
    }

    //示例方法
    public void showMessage(){
        System.out.println("Hello World from Singletion");
    }
}